package com.chinatelecom.framework.model;

import java.util.HashMap;

/**
 * 接口统一返回格式
 * */
public class R extends HashMap<String, Object> {

    private static final long serialVersionUID = 1;

    public R message(String message) {
        this.put("message", message);
        return this;
    }

    public R data(Object data) {
        this.put("data", data);
        return this;
    }

    @Override
    public R put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public static R ok() {
        R r = new R();
        r.put("code", 0);
        r.put("msg", "请求成功");
        return r;
    }

    public static R ok(String msg) {
        R r= new R();
        r.put("code", 0);
        r.put("msg", msg);
        return r;
    }
}
